<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class index extends CI_Controller {

	function __construct(){
        // Call the Model constructor
        parent::__construct();
        //$this->lang->load('vt');
        //$this->load->library('form_validation');
        //$this->load->helper('form');
        //$this->load->helper('date');
    }
    
	public function index()
	{
        //$this->template->set_regions('header','<h3>Hearder ne con</h3>');
        //$this->template->set_regions('footer','<h3>Footer ne con</h3>');
        //echo "ssssss";
        //$this->template->set('bien','1002');
        
        //$this->template->set_view('home/content');
        
        //$this->template->render();
        //redirect('rp');
		$this->login();
	}
    
    public function login(){
        if( $this->session->userdata('logged_in') === true ){
            redirect('home');
        }
        
        if ($_SERVER['REQUEST_METHOD'] == 'POST'){
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            
            $user = $this->jimauth->login($username,$password);
            if($user){
                redirect('home');
            }else{
                redirect('login');
            }
        }
        $this->load->view($this->template->template.'/page/login_page');
    }
    
    public function logout(){
        //$this->session->unset_userdata('logged_in');
        $this->session->sess_destroy();
        redirect('index');
    }
    
    public function no_access(){
        echo 'Ban khong du quyen han de truy cap';
    }
    
    public function test(){
        /*$this->load->library('khvt_report');
        $khvtReport = new khvt_report();
        $report_code = date("Y-m-d");
        $khvtReport->render_report($report_code);*/
        echo formatMoney(1.7531598); # 1,050 
    }
     
    
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */